package com.design.cjm.behavioral.strategy.example2;

import com.design.cjm.behavioral.strategy.example2.impl.ConcreteStrategyA;
import com.design.cjm.behavioral.strategy.example2.impl.ConcreteStrategyB;

/**
 * @Author: Jie Ming Chen
 * @Date: 2018/9/17
 * @Version 1.0
 */
public class StrategyFactoryContext {

    private AbstractStrategy abstractStrategy;

    public StrategyFactoryContext(String type){

        AbstractStrategy instance = null;

        switch (type){
            case "A" :

                instance = new ConcreteStrategyA();
                break;
            case "B" :
                instance = new ConcreteStrategyB();
                break;
                
            default:
                break;
        }

        this.abstractStrategy = instance;
    }

    // 具体结果
    public void contextInterface(){
        abstractStrategy.algorithmInterface();
    }
}
